package com.demo.utils;

import java.util.List;

public class Result<T> {
    private String msg;
    private Integer code;
    private T data;

    public Result() {
    }

    public static <S>Result<S> getInstance(Class<S> type){
        Result<S> result=new Result<>();
        return result.setCode(200).setMsg("请求成功");
    }
    public static Result<?> getInstance(){
        Result<?> result=new Result<>();
        return result.setCode(200).setMsg("请求成功");
    }
    public static <S>Result<List<S>> getInstanceList(Class<S> type){
        Result<List<S>> result=new Result<>();
        return result.setCode(200).setMsg("请求成功");
    }
    public String getMsg() {
        return msg;
    }

    public Result<T> setMsg(String msg) {
        this.msg = msg;
        return this;
    }

    public Integer getCode() {
        return code;
    }

    public Result<T> setCode(Integer code) {
        this.code = code;
        return this;
    }

    public T getData() {
        return data;
    }

    public Result<T> setData(T data) {
        this.data = data;
        return this;
    }

    public void fail(int code, String msg, T data) {
        this.code = code;
        this.msg = msg;
        this.data = data;
    }
}
